﻿using CyberWin.CSHARP.YNWLZC.WebFrame.CyberPHP.CyberWinWeb.WebData;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace CyberWin.Trade.IDE.Server
{
    public static class cl_东方仙盟_ide个性化数据
    {
        //

        public static void ide_初始化()
        {
            string 数据库路径 = Application.StartupPath+"/cyberwinide_setting.whcv";
            string dbType = "SQLite";
            string[] conn = new string[1];
            conn[0] = 数据库路径;
            Cyber_DataBase cdb = new Cyber_DataBase(dbType, conn);
           
              //CyberWin.Trade.Local.BaseMaterialManagement.CyberWin_Common.Cyber_Public.设置全局数据库();
        }
            public static void ide_add收藏(string token ,string 项目,string 标题, string type ,string 路径)
        {
            ide_初始化();
            //cyberwin_ide_favourite
            //cyberwin_ide_history
            //cyberwin_ide_settings
            Cyber_M db = new Cyber_M("ide_favourite", "cyberwin_");
            NameValueCollection 收藏= new NameValueCollection();
            收藏.Add("token", token);
            收藏.Add("项目", 项目);
            收藏.Add("标题", 标题);
            收藏.Add("类型", type);
            收藏.Add("路径", 路径);
            收藏.Add("create_time", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            db.Add(收藏);



        }

        public static string ide_get收藏(string token, string 项目, string 标题, string type, string 路径)
        {
            ide_初始化();
            //cyberwin_ide_favourite
            //cyberwin_ide_history
            //cyberwin_ide_settings
            Cyber_M db = new Cyber_M("ide_favourite", "cyberwin_");
            //NameValueCollection 收藏 = new NameValueCollection();
            //收藏.Add("token", token);
            //收藏.Add("项目", 项目);
            // 收藏.Add("标题", 标题);
            // 收藏.Add("类型", type);
            // 收藏.Add("路径", 路径);
            // 收藏.Add("create_time", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            //  db.Add(收藏);
              db.where("");

              DataTable dt= db.Select();

            string 未来之窗ret = JsonConvert.SerializeObject(dt);
            return 未来之窗ret;




        }

        public static void ide_del收藏(string token, string id)
        {
            ide_初始化();
            //cyberwin_ide_favourite
            //cyberwin_ide_history
            //cyberwin_ide_settings
            Cyber_M db = new Cyber_M("ide_favourite", "cyberwin_");
            //NameValueCollection 收藏 = new NameValueCollection();
            //收藏.Add("token", token);
            //收藏.Add("项目", 项目);
            // 收藏.Add("标题", 标题);
            // 收藏.Add("类型", type);
            // 收藏.Add("路径", 路径);
            // 收藏.Add("create_time", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            //  db.Add(收藏);
            db.where("cyber_id ="+id);

             db.Delete();

            



        }


        public static void ide_add历史(string token, string 项目, string 标题, string type, string 路径)
        {
            ide_初始化();
            //cyberwin_ide_favourite
            //cyberwin_ide_history
            //cyberwin_ide_settings
            Cyber_M db = new Cyber_M("ide_history", "cyberwin_");
            NameValueCollection 收藏 = new NameValueCollection();
            收藏.Add("token", token);
            收藏.Add("项目", 项目);
            收藏.Add("标题", 标题);
            收藏.Add("类型", type);
            收藏.Add("路径", 路径);
            收藏.Add("create_time", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            db.Add(收藏);



        }


    }
}
